//
//  ThreeTableViewCell.m
//  DaJiHui
//
//  Created by Hao on 2017/7/7.
//  Copyright © 2017年 Hao. All rights reserved.
//
#import "UIImageView+WebCache.h"
#import "ThreeTableViewCell.h"

@implementation ThreeTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setFrame:(CGRect)frame
{
    //修改cell的左右边距为10;
    //修改cell的Y值下移10;
    //修改cell的高度减少10;
    if (_isFormFirst) {
        static CGFloat margin = 10;
        frame.origin.x = margin;
        frame.size.width -= 2 * frame.origin.x;
        frame.origin.y += 0;
        frame.size.height -= 0;
        
        [super setFrame:frame];
    }else{
        static CGFloat margin = 10;
        frame.origin.x = margin;
        frame.size.width -= 2 * frame.origin.x;
        frame.origin.y += 0;
        frame.size.height -= 0;
        
        [super setFrame:frame];
    }
    
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.imageView_photo = [[UIImageView alloc]init];
        [self.contentView addSubview:self.imageView_photo];
        
        self.imageView_tip1 = [[UIImageView alloc]init];
        [self.contentView addSubview:self.imageView_tip1];
        
        self.imageView_tip2 = [[UIImageView alloc]init];
        [self.contentView addSubview:self.imageView_tip2];
        
        self.labelName = [[UILabel alloc]init];
        [self.contentView addSubview:self.labelName];
        
        self.labelJob = [[UILabel alloc]init];
        [self.contentView addSubview:self.labelJob];
        
        self.labelYear = [[UILabel alloc]init];
        [self.contentView addSubview:self.labelYear];
        
        self.labelDetail = [[UILabel alloc]init];
        [self.contentView addSubview:self.labelDetail];
        
        self.labelTrain = [[UILabel alloc]init];
        [self.contentView addSubview:self.labelTrain];
        
        self.labelPrice = [[UILabel alloc]init];
        [self.contentView addSubview:self.labelPrice];
        
        self.labelDistance = [[UILabel alloc]init];
        [self.contentView addSubview:self.labelDistance];
        
        self.DBtn = [[UIButton alloc]init];
        [self.contentView addSubview:self.DBtn];
        
        self.QBtn = [[UIButton alloc]init];
        [self.contentView addSubview:self.QBtn];
        
        self.TBtn = [[UIButton alloc]init];
        [self.contentView addSubview: self.TBtn];
        
        
    }
    return self;
}
- (void)layoutSubviews
{
    
    [super layoutSubviews];
    
    self.layer.cornerRadius = 6;
    self.layer.shadowOffset =CGSizeMake(0, 5);
    self.layer.shadowColor = [UIColor grayColor].CGColor;
    self.layer.shadowRadius = 1;
    self.layer.shadowOpacity = .5f;
    self.layer.masksToBounds = NO;
    //    self.imageView_photo.image = [UIImage imageNamed:@"desktop.jpg"];
    self.imageView_photo.contentMode = UIViewContentModeScaleToFill;
    self.imageView_photo.layer.cornerRadius = 0;
    self.imageView_photo.clipsToBounds = YES;
    self.labelName.font = [UIFont systemFontOfSize:18];
    self.imageView_tip2.image = [UIImage imageNamed:@"position"];
    self.imageView_tip1.image = [UIImage imageNamed:@"length_of_service"];
    self.labelYear.textColor = kColor909090;
    self.labelYear.font = [UIFont systemFontOfSize:12];
    self.labelJob.font = [UIFont systemFontOfSize:12];
    self.labelJob.textColor = kColor909090;
    self.labelDetail.font = [UIFont systemFontOfSize:13];
    self.labelDetail.textColor =kColor909090;
    self.labelJob.textAlignment = NSTextAlignmentRight;
    self.labelTrain.textColor =kColor909090;
    self.labelTrain.font = [UIFont systemFontOfSize:12];
    self.labelDistance.textColor =kColor909090;
    self.labelDistance.font = [UIFont systemFontOfSize:12];
    self.labelPrice.textColor =[UIColor redColor];
    self.labelPrice.font = [UIFont systemFontOfSize:14];
    [self.imageView_photo mas_makeConstraints:^(MASConstraintMaker *make) {
        //       make.left.equalTo
        make.left.equalTo(self.contentView).offset(5);
        make.centerY.equalTo(self.contentView);
        make.size.mas_equalTo(CGSizeMake(85, 65));
        
    }];
    
    [self.labelName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.imageView_photo.mas_right).offset(15);
        make.top.equalTo(self.imageView_photo.mas_top);
        make.size.mas_equalTo(CGSizeMake(ZTY_SCREEN_WIDTH, 18));
        
    }];
    
    [self.labelYear mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.contentView.mas_right).offset(-15);
        make.top.equalTo(self.imageView_photo);
        make.size.mas_equalTo(CGSizeMake(80, 15));
    }];
    self.labelYear.text = [NSString stringWithFormat:@"已评价：0"];
    
    [self.labelDetail mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.labelName);
        make.bottom.equalTo(self.imageView_photo);
        make.size.mas_equalTo(CGSizeMake(80, 15) );
    }];
    [self.labelJob mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.labelYear.mas_right);
        make.bottom.equalTo(self.imageView_photo);
        make.size.mas_equalTo(CGSizeMake(ZTY_SCREEN_WIDTH/2-50, 15) );
    }];
    self.labelJob.text=[NSString stringWithFormat:@"大庆市服务外包园A1-3"];
    self.labelDetail.text= [NSString stringWithFormat:@"已售：8 份"];
    self.imageView_photo.image = [UIImage imageNamed:@"eat_00"];
    self.labelName.text = [NSString stringWithFormat:@"名字"];
}
//

- (void)setMyModel:(FirstModel *)myModel{
    if (_myModel != myModel) {
        _myModel = myModel;
    }
    
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

+ (CGFloat )cellheight{
    return 95;
}

@end
